package com.ntv.service.event;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.ntv.domain.IEvent;
import com.ntv.persistent.PersistentException;
import com.ntv.persistent.event.IEventDao;
import com.ntv.service.DomainException;

/**
 * 
 * @author Vedamoorthi Vairam
 * @since 03/02/2009
 *
 */
public class EventAppService implements IEventAppService {
	
	@Autowired
	private IEventDao eventDao;

	/**
	 * @param eventDao the eventDao to set
	 */
	public void setEventDao(IEventDao eventDao) {
		this.eventDao = eventDao;
	}
	
	
	public List<IEvent> getEvents() throws DomainException 
	{
		try
		{
			return eventDao.getEvents();
		}
		catch (PersistentException e)
		{
			throw new DomainException(e);
		}
	}
	
	public IEvent findEventByID(Long eventId) throws DomainException 
	{
		
		try
		{
			return eventDao.findEventByID(eventId);
		}
		catch (PersistentException e)
		{
			throw new DomainException(e);
		}
	}
	
	public List<IEvent> findEventsByEventDate(Date eventDate) throws DomainException 
	{
		try
		{
			return eventDao.findEventsByEventDate(eventDate);
		}
		catch (PersistentException e)
		{
			throw new DomainException(e);
		}
	}
	
	public IEvent createEvent(IEvent event)  throws DomainException 
	{
		try
		{
			return eventDao.createEvent(event);
		}
		catch (PersistentException e)
		{
			throw new DomainException(e);
		}
	}
}
